package com.smart.store.config;

import com.smart.store.filter.TokenFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FilterConfig {

    @Autowired
    TokenFilter tokenFilter;

    @Bean
    public FilterRegistrationBean registerTokenFilter() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(tokenFilter);
        registration.addUrlPatterns("/*");
        registration.setName("authFilter");//手动注册进去
        registration.setOrder(1);  //值越小，Filter越靠前。
        return registration;
    }
}
